package com.nlp.weixin.web.core;

import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.core.JFinal;
import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.c3p0.C3p0Plugin;
import com.nlp.weixin.web.beetl.BeetlRenderFactory;
import com.nlp.weixin.web.controller.IndexController;


/**
 * 
 * @author zyl
 *
 */
public class GlobalConfig extends JFinalConfig {

  @Override
  public void configConstant(Constants me) {
//     PropKit.use("development.properties"); // 开发或测试模式
    PropKit.use("production.properties"); // 生产模式

    me.setMainRenderFactory(new BeetlRenderFactory());

    me.setDevMode(PropKit.getBoolean("sys.dev_model", false));
    me.setEncoding("UTF-8");
    
  }

  @Override
  public void configRoute(Routes me) {
    me.add("/", IndexController.class);
  }

  @Override
  public void configPlugin(Plugins me) {

//    C3p0Plugin c3p0Plugin =
//        new C3p0Plugin(PropKit.get("jdbc.url"), PropKit.get("jdbc.user"), PropKit.get(
//            "jdbc.password").trim());
//    me.add(c3p0Plugin);
//    
//    ActiveRecordPlugin arp = new ActiveRecordPlugin("fcj",c3p0Plugin);
//    me.add(arp);
    
  }
  //全局拦截器
  @Override
  public void configInterceptor(Interceptors me) {
  }

  @Override
  public void configHandler(Handlers me) {

  }

  public static void main(String[] args) {
    JFinal.start("src/main/webapp", 8080, "/", 50);
  }
  
  @Override
  public void beforeJFinalStop() {
  }
}
